<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2018/3/13
  Time: 15:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div id="page-content">
  <div class="row">
    <div class="col-lg-12">
      <div class="panel">
        <div class="panel-heading">
          <h3 class="panel-title">人员信息管理</h3>
        </div>
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="btn_add_person" class="btn btn-primary btn-sm" ${isCreate}>
                  <i class="ti-plus"></i> 新建人员信息
                </btn>
                <%--<btn id="init2018" class="btn btn-primary btn-sm" ${isCreate}>--%>
                  <%--<i class="ti-plus"></i> 点击初始化2018-2021数据--%>
                <%--</btn>--%>
              </div>
            </div>
          </div>

          <div class="table-jqgrid">
            <table id="person_table"></table>
            <div id="person_page"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

<script>

  $(function(){
    init_grid_person();
  });

  function init_grid_person() {

        __init_jqgrid('person_table', 'person_page',
                '<%=path%>/com/person/list?viewtype=${viewtype}&streetId=${streetId}',
                ['所属区',"街道（镇）",'姓名',"性别","年龄","学历","人员性质","是否一肩挑","居民区","文档状态","操作","id","isDirector"],
                [
                  {name:'area',index:'area', width:80,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                  {name:'street',index:'street', width:80,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                  {name:'name',index:'name', width:80,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                  {name:'gender',index:'gender',sortable:true,search:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'age',index:'age',sortable:true,search:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'highEdu',index:'highEdu', search:true,sortable:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'personNature',index:'personNature', search:true,sortable:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'shoulder',index:'shoulder', search:true,sortable:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'resident',index:'resident', search:true,sortable:true,width:80, searchoptions: {sopt: ['cn']}},
                  {name:'state',index:'state', search:true,sortable:true,width:60, searchoptions: {sopt: ['cn']}},
                  {name:'act',index:'act', width:250,sortable:false,search:false,fixed:true,formatter: actFormat},
                  {name:'id',index:'id',search:false,hidden:true},
                  {name:'isDirector',index:'isDirector',search:false,hidden:true}
                ],
                true,true
        );

  }


  function actFormat(cellvalue, options, rowObject){
    var id = rowObject.id;
    var isDirector = rowObject.isDirector;
    cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_person_read(\'' + id + '\',\'' + isDirector + '\',\'' + ${viewtype} + '\');"><i class="fa fa-eye"> </i> 查看</button>';
    <%--<c:if test="${viewtype==3 || viewtype==6}">--%>
    <%--cellvalue += '<button class="btn btn-white btn-sm" onclick="fn_person_edit(\'' + id + '\',\'' + isDirector + '\');"><i class="fa fa-eye"> </i> 编辑</button>';--%>
    <%--cellvalue += '<button class="btn btn-white btn-sm" onclick="fn_person_delete(\'' + id + '\',\'' + isDirector + '\');"><i class="fa fa-eye"> </i> 删除</button>';--%>
    <%--</c:if>--%>
    return cellvalue;
  }

  function fn_person_read(id,isDirector,viewtype) {
    loadURL('<%=path%>/com/person/read?keyId='+id+'&isDirector='+isDirector+'&viewtype='+viewtype, $('#page-content'));
  }

  $("#btn_add_person").click(function(){
    loadURL('<%=path%>/com/person/input?isDirector=${viewtype==5||viewtype==6 ? 1 : 0}&viewtype=${viewtype}', $('#page-content'));
  });

  $("#init2018").click(function(){
    __ajax_get("<%=path%>/com/person/init2015",{},function(data){
      console.log(data);
    })
  });

</script>